package cn.koala.key.accounts.controller;

import cn.koala.key.accounts.service.AuthManageService;
import cn.koala.key.accounts.util.AuthFunAndModule;
import cn.seed.common.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 权限管理
 * @description
 * @return
 * @Exception
 * @author shuai.xu
 * @time 2019/6/27 10:59
*/
@Api(tags = "权限管理")
@RestController
@RequestMapping(value = "/authManage", produces = "application/json")
public class AuthManageController {
	
	@Autowired
	private AuthManageService authManageService;

	/**
	 * 获取权限列表
	 * @description getAuthTreeByName
	 * @param userCode
	 * @return cn.seed.common.core.Result<java.lang.Object>
	 * @Exception
	 * @author shuai.xu
	 * @time 2019/6/27 10:57
	*/
	@ApiOperation(notes = "获取权限列表", value = "获取权限列表")
	@GetMapping("/getAuthTreeByName")
	public Result<Object> getAuthTreeByName(@RequestParam("userCode") String userCode) {
		return authManageService.getAuthTreeByName("KoalaKey", userCode);
	}

	/**
	 * 根据工号获取模块Id获取按钮权限
	 * @description getAuthBtnAuth
	 * @param userCode
	 * @param moduleId
	 * @return cn.seed.common.core.Result<java.util.List<cn.koala.key.accounts.util.AuthFunAndModule>>
	 * @Exception
	 * @author shuai.xu
	 * @time 2019/6/27 10:57
	*/
	@ApiOperation(value = "根据工号获取模块Id获取按钮权限")
	@GetMapping("/auth/btnAuth")
	Result<List<AuthFunAndModule>> getAuthBtnAuth(@RequestParam("userCode") String userCode,
												  @RequestParam("moduleId") String moduleId){
		return authManageService.getAuthBtnAuth("KoalaKey", userCode, moduleId);
	}
}
